package formValidate

import (
	"github.com/go-playground/validator/v10"
	"regexp"
)

type RegisterValidate struct {
	Username string `json:"username" binding:"required,min=1,max=5"`
	Password string `json:"password" binding:"required"`
	NickName string `json:"nickName" binding:"required"`
	Mobile   string `json:"mobile" binding:"required,ValidateMobile"`
}

type RegisterReq struct {
	name string `json:"name"  binding:"required"`
}

type LoginValidate struct {
	Username string `json:"username" binding:"required,min=1,max=5"`
	Password string `json:"password" binding:"required"`
	Mobile   string `json:"mobile" binding:"required"`
}

// 手机号验证函数
func ValidateMobile(fl validator.FieldLevel) bool {
	mobilePattern := `^1[3-9]\d{9}$`              // 中国大陆手机号正则表达式
	regex := regexp.MustCompile(mobilePattern)    //编译正则表达式
	return regex.MatchString(fl.Field().String()) //执行匹配
}

type UserInfoValidate struct {
	Uid uint `json:"uid" binding:"required"`
}

type Page struct {
	Page     uint `json:"page" `
	PageSize uint `json:"pageSize" `
}
